#include <Click_Interrupt_Config.h>

//对P1.1、P1.4设置按键中断
//NVIC->ISER[1] |= Click_Interrupt_Init();
uint32_t Click_Interrupt_Init(void)
{


    P5->DIR |= BIT0;
    P5->DIR &= ~BIT2;
    P5->IES &= ~BIT2;
    P5->IFG = 0;
    P5->IE |= BIT2;
    P3->DIR &= (~BIT5)|(~BIT6)|(~BIT7);
    P3->IES &= (~BIT5)|(~BIT6)|(~BIT7);
    P3->IFG = 0;
    P3->IE |= BIT5|BIT6|BIT7;

    P1->DIR &= ~(uint8_t) (BIT1|BIT4);
    P1->OUT |= BIT1|BIT4;
    P1->REN |= BIT1|BIT4;                         // Enable pull-up resistor (P1.1 output high)
//    P1->SEL0 = 0;
//    P1->SEL1 = 0;
    P1->IES |= BIT1|BIT4;                         // Interrupt on high-to-low transition
    P1->IFG = 0;                            // Clear all P1 interrupt flags
    P1->IE |= BIT1|BIT4;                          // Enable interrupt for P1.1
    __enable_irq();
        return (1 << ((PORT3_IRQn) & 31)) + (1 << ((PORT5_IRQn) & 31)) +   (1<<((PORT1_IRQn) & 31));
}

//中断检测按下的按键
//void PORT1_IRQHandler(void){}
int Click_IRQ(void)
{
    if(P1->IFG & BIT1)
    {
        P1->IFG &= ~BIT1;
        return 11;
    }
    else if(P1->IFG & BIT4)
    {
        P1->IFG &= ~BIT4;
        return 14;
    }
    else if(P3->IFG & BIT5)
    {
        P3->IFG &= ~BIT5;
        return 35;
    }
    else if(P3->IFG & BIT6)
    {
        P3->IFG &= ~BIT6;
        return 36;
    }
    else if(P3->IFG & BIT7)
    {
        P3->IFG &= ~BIT7;
        return 37;
    }
    else if(P5->IFG & BIT2)
    {
        P5->IFG &= ~BIT2;
        return 52;
    }


}
